import { getServerResponses } from './index.js';
import { fromBase64toFloat } from './base64.js';

onmessage = (event) => {
	let res = event.data.res;
	let key = event.data.key;
	let iv = event.data.iv;
	// console.log()
	let globalData = getServerResponses(res, key, iv);

	if (globalData.result && globalData.result.data && globalData.result.data.length) {
		for (let i = 0; i < globalData.result.data.length; i++) {
			for (let j = 0; j < globalData.result.data[i].datas.length; j++) {
				let values = globalData.result.data[i].datas[j].values;
				globalData.result.data[i].datas[j].values = fromBase64toFloat(values);
			}
		}
	}

	// console.log("webworker计算完成",new Date().getTime())
	postMessage(globalData);
	// countDown(para)
};
